package servlet;

import hibernate.DictInfo;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import DAO.DictInfoDAO;

/**
 * Servlet implementation class getAssetType
 */
public class getAssetType extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public getAssetType() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/plain");
		PrintWriter out = response.getWriter();   
		@SuppressWarnings("unchecked")
        List getType;
		DictInfoDAO dictdao = new DictInfoDAO();
		getType = dictdao.getAllAssetType();
		
		String s = "{type:[";
        for(int i=0;i<getType.size();i++)
        {     	
			s = s + "{type:" + "'" + getType.get(i) + "'},";
        }
        s += "{type:'All'},";
        if(!"{type:[".equals(s))
        {
        	s = s.substring(0, s.length()-1);
        }
        
        s = s + "]}";
        out.println(s);
        out.flush();		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request,response);
	}

}
